home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / CinemaSystem.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  3.0 KB  |  120 lines

  1.  
  2. -- We need to be able to place some traps, but not have it cost anything. 
  3. function TrapPlace( textname , place, face)
  4.     G.edit( true )
  5.     G.AttemptTrapDrop(textname, place, face); 
  6.     G.edit( false )
  7. end
  8.  
  9. -- Cinematic Code:
  10. function StartCinematic()
  11.     -- Put up the Bars, Disable actions
  12.     ActivateCinemaBars();
  13.     
  14.     if( Camera ~= nil ) then
  15.         Camera.EnterCinemaMode()
  16.         cinemaCameraStartPos = Camera.GetPosition()
  17.         cinemaCameraStartDir = Camera.GetDirection() + cinemaCameraStartPos
  18.     end
  19.     
  20.     -- Disable / Hide the cursor
  21.     G.SetCursorActive( false );
  22.     
  23.     if( Cursor ~= nil ) then
  24.         Cursor.SetVelocity( Vector3(0,0,0) )
  25.         Cursor.SetPosition( Vector3(0,0,0) )
  26.         
  27.         --  Have the cursor stop dropping any trap
  28.         Cursor.ExitTrapMode();
  29.     end
  30.     
  31.     -- PAUSE INVADERS
  32. end
  33.  
  34. function EndCinematic()
  35.     -- Remove bars, Enable actions
  36.     DeactivateCinemaBars()
  37.     
  38.     if( Camera ~= nil ) then
  39.     Camera.RegularMove( cinemaCameraStartPos, cinemaCameraStartDir, 0.5 )
  40.     end
  41. --    Camera.ExitCinemaMode()
  42.     G.SetCursorActive( true );
  43.     
  44.     -- RESUME INVADERS
  45. end
  46.  
  47. ----------------------------------------------------------------
  48. --    Bars Code
  49. ----------------------------------------------------------------
  50.  
  51.  
  52. CinemaBarsProgress = 0.0    -- From 0 to 1 (offscreen / final pos)
  53. CinemaBarsMovement = 0.0    -- Movement direction (Down / up)
  54.  
  55. function ActivateCinemaBars()
  56.     if( CinemaBars == nil or not( CinemaBars.IsValid()) ) then
  57.         G.Create( "MenuData/CinemaBarsCog.xml" );
  58.     end
  59.     
  60.     CinemaBarsProgress = 0.0
  61.     CinemaBarsMovement = 1.0
  62.     
  63.     if( HUD ~= nil ) then
  64.         HUD.CloseWindow( "CombinedHUDWindow" );
  65.     end
  66. end
  67.  
  68. function DeactivateCinemaBars()
  69.     CinemaBarsMovement = -1.0
  70.     if( HUD ~= nil ) then
  71.         HUD.OpenWindow( "CombinedHUDWindow" );        
  72.     end
  73.  
  74. end
  75.  
  76. function KillCinemaBars()
  77.     if( CinemaBars ~= nil and CinemaBars.IsValid() ) then
  78.         CinemaBars.Destroy();
  79.         if( HUD ~= nil ) then
  80. --            HUD.OpenWindow( "CombinedHUDWindow" );        
  81.         end
  82.     end
  83. end
  84.  
  85. function UpdateCinemaBars()
  86.  
  87.     if( CinemaBars ~= nil and CinemaBars.IsValid() ) then
  88.         -- Bars should start off screen and move (fade?) on
  89.         CinemaBarsProgress = CinemaBarsProgress + CinemaBarsMovement * GameTimeDiff;
  90.  
  91.         if( CinemaBarsProgress < 0.0 ) then            -- Off screen 
  92.             CinemaBarsProgress = 0.0
  93.             KillCinemaBars()
  94.         else
  95.         
  96.             if( CinemaBarsProgress > 1.0 ) then
  97.                 CinemaBarsProgress = 1.0
  98.             end
  99.             
  100.             curPos = CinemaBarsProgress * 0.2
  101.             CinemaBars.SetGuiPosition( "TopCinemaBar",        Vector3(0, 1.0 - curPos, 0) );
  102.             CinemaBars.SetGuiPosition( "BottomCinemaBar",    Vector3(0, -1.0 + curPos, 0) );
  103.  
  104.             barFadeColor = Color(1,1,1, CinemaBarsProgress );
  105.             CinemaBars.SetColor( "TopCinemaBar", barFadeColor );
  106.             CinemaBars.SetColor( "BottomCinemaBar", barFadeColor );
  107.         
  108.         end
  109.     end
  110.  
  111. end
  112.  
  113. -- Always update Function:
  114. GMain[ "UpdateCinemaBars" ] = UpdateCinemaBars;
  115.  
  116. -------------------------------------------------------------------------------
  117. --        Other Cinema Functions
  118. -------------------------------------------------------------------------------
  119.  
  120.